# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rdiscount
_gemname=rdiscount
pkgver=2.2.0.2
pkgrel=1
pkgdesc="Fast Implementation of Gruber's Markdown in C"
url="http://dafoster.net/projects/rdiscount/"
arch="all"
license="BSD-3-Clause"
checkdepends="perl ruby-test-unit tidyhtml"
makedepends="ruby-dev ruby-rake"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/davidfstr/$_gemname/archive/$pkgver.tar.gz
	fix-rakefile.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

build() {
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	install -D -m 755 bin/$_gemname "$pkgdir"/usr/bin/$_gemname

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver

	install -D -m644 man/$_gemname.1 -t "$pkgdir"/usr/share/man/man1/
	install -D -m644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/

	# Remove unnecessary files and rubbish...
	rm -r ext/ lib/*.so man/ test/ COPYING Rakefile BUILDING README* || true
}

sha512sums="
a2635bba5561ac4533c20010fbfe13191b0a182e6e2b3ea7da9a33abba7c26affb25ed1ff174149b528d5e83c930842972c6bc42f6d0d8623e3c0689b32528a3  ruby-rdiscount-2.2.0.2.tar.gz
eef24dd1a1bafd0efc27cb7097d5cd26d2ef0daeea2daf57f665d309352561fb79012faf3be2a1e584f735ed3b36ab6dc3fb975c78b8331a38d971b280d75eac  fix-rakefile.patch
"
